package com.app.utils;

import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
import me.chanjar.weixin.mp.config.WxMpConfigStorage;
import me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class WXConstant {

    //益联宝微信小程序
    public static final String APPID = "wxe0b38eb31773da10";

    public static final String SECRET = "df233b68d283e18a297ecaf338f30202";

    //益联宝微信公众号
    public static final String Official_Account_Appid = "wx0b6106482d6f6120";

    public static final String Official_Account_Secret = "98ca38456f01f99c436b2cf646a95dce";

    /**
     * 微信客户端配置存储
     *
     * @return
     */
    @Bean
    public static WxMpConfigStorage wxMpConfigStorage() {
        WxMpDefaultConfigImpl configStorage = new WxMpDefaultConfigImpl();
        // 公众号appId
        configStorage.setAppId(APPID);
        // 公众号appSecret
        configStorage.setSecret(SECRET);
        return configStorage;
    }

    /**
     * 声明实例
     *
     * @return
     */
    @Bean
    public static WxMpService wxMpService() {
        WxMpService wxMpService = new WxMpServiceImpl();
        wxMpService.setWxMpConfigStorage(wxMpConfigStorage());
        return wxMpService;
    }



    /**
     * 微信客户端配置存储
     *
     * @return
     */
    @Bean
    public static WxMpConfigStorage officialAccountWxMpConfigStorage() {
        WxMpDefaultConfigImpl configStorage = new WxMpDefaultConfigImpl();
        // 公众号appId
        configStorage.setAppId(Official_Account_Appid);
        // 公众号appSecret
        configStorage.setSecret(Official_Account_Secret);
        return configStorage;
    }

    /**
     * 声明实例
     *
     * @return
     */
    @Bean
    public static WxMpService officialAccountwxMpService() {
        WxMpService wxMpService = new WxMpServiceImpl();
        wxMpService.setWxMpConfigStorage(officialAccountWxMpConfigStorage());
        return wxMpService;
    }
}
